package phoenics.manpads.common.mybatis.page;

import java.util.Map;

/**
 * @author Phoenics Chow
 * on 2018年12月11日
 */
public class PageUtils {
    private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(PageUtils.class);
    public static boolean pageable(Object parameter){
        boolean rt=false;
        RequestPage page=takePage(parameter);
        if (null != page && page.getPageSize() > -1) {
            rt=true;
        }
        return rt;
    }
    public static RequestPage takePage(Object parameter){
        RequestPage page = null;
        if (parameter instanceof RequestPage) {
            page = (RequestPage) parameter;
        } else if (parameter instanceof Map) {
            for (Object arg : ((Map) parameter).values()) {
                if (arg instanceof RequestPage) {
                    page = (RequestPage) arg;
                    break;
                }
            }
        }
        return page;
    }


}
